package com.controller.qd;

import java.text.SimpleDateFormat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.ajax.AjaxRes;
import com.common.mybatis.Page;
import com.controller.base.BaseController;
import com.entity.Information;
import com.service.AppendixRelationshipService;
import com.service.informationService;

@Controller
@RequestMapping("/qdNews/")
public class NewsController extends BaseController<Object>{

	@Autowired
	private informationService infoservice;
	/**
	 * 分页查询
	 * @return
	 */
	@RequestMapping("/findByPage")
	@ResponseBody
	public AjaxRes findByPage(Information info,Page<Information> p,String id){
		AjaxRes res = new AjaxRes();
		info.setColumnNumber(id);
		try {
			Page<Information> pageUis = infoservice.showInfo(info, p, info.getColumnNumber());
			// 获得SimpleDateFormat类
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			for (int i = 0; i < pageUis.getResults().size(); i++) {
				//转换时间格式
				pageUis.getResults().get(i).setReleaseTimeToString(sf.format(pageUis.getResults().get(i).getReleaseTime()));
			}
			res.setSucceed(pageUis, "数据获取成功");
		} catch (Exception e) {
			Page<Information> pageUis = null;
			res.setSucceed(pageUis,"没有数据");
		}
		return res;
	}
}
